import { AUTH_TYPE_MAP, WITHDRAW_AUTH_STATUS_ACTION_MAP } from '@/const/user'
import { formatTime, renderMaybeNull } from '@/utils';
import type { DataTableProps } from 'naive-ui';
import { NImage } from 'naive-ui';
import { h } from 'vue';

export const withdrawColumns: DataTableProps['columns'] = [
	{
		title: '用户ID',
		key: 'userId',
		width: 180,
	},
	{
		title: '提现类型',
		key: 'addressType',
		width: 80,
		render: item => renderMaybeNull(item.addressType),
	},
	{
		title: '提现账号',
		key: 'addressBankNumber',
		width: 100,
		render: item => renderMaybeNull(item.addressBankNumber),
	},
	{
		title: '开户行',
		key: 'addressBankAddress',
		width: 100,
		render: item => renderMaybeNull(item.addressBankAddress)
	},
	{
		title: '卡号名称',
		key: 'addressBankUserName',
		width: 100,
		render: item => renderMaybeNull(item.addressBankUserName)
	},
	{
		title: '商品封面',
		key: 'addressQrCode',
		width: 100,
		render: item => h('div', {
			style: {
				width: '100%',
				display: 'flex',
				alignItems: 'center',
				justifyContent: 'center',
			}
		}, [
			h(NImage, {
				src: item.addressQrCode,
				height: 70,
				width: '100%',
				objectFit: 'contain',
				style: {
					width: '100%',
					height: '100%',
					backgroundColor: 'rgba(0,0,0,0.5)',
					backdropFilter: 'blur(5px)',
				}
			})
		])
	},
	{
		title: '提现金额',
		key: 'amount',
		width: 100,
		render: item => renderMaybeNull(item.amount)
	},
	{
		title: '提现状态',
		key: 'status',
		width: 100,
		render: item => h('div', {
			style: {
				color: item.status === 1 ? 'var(--primary-color)' : item.status === 2 ? 'var(--error-color)' : ''
			},
		}, [WITHDRAW_AUTH_STATUS_ACTION_MAP[item.status]])
	},
	{
		title: '有效性',
		key: 'valid',
		width: 100,
		render: item => renderMaybeNull(item.valid)
	},
	{
		title: '到账状态',
		key: 'infoStatus',
		width: 100,
		render: item => renderMaybeNull(item.infoStatus)
	},
	{
		title: '备注信息',
		key: 'remark',
		width: 100,
		render: item => renderMaybeNull(item.remark)
	},
]

export const auditUserColumns: DataTableProps['columns'] = [
	{
		title: '姓名',
		key: 'name',
		width: 80,
		render: item => renderMaybeNull(item.name),
	},
	{
		title: '手机号',
		key: 'phone',
		width: 120,
	},
	{
		title: '身份证号码',
		key: 'idcard',
		width: 200,
	},
	{
		title: '认证类型',
		key: 'type',
		width: 100,
		render: (item: any) => AUTH_TYPE_MAP[item.type] || item.type
	},
	{
		title: '身份证（正面）',
		key: 'idcardFront',
		width: 130,
		render: item => h(NImage, {
			src: item.idcardFront,
			height: 50,
			width: 100,
			objectFit: 'contain',
		})
	},
	{
		title: '身份证（反面）',
		key: 'idcardBack',
		width: 130,
		render: item => h(NImage, {
			src: item.idcardBack,
			height: 50,
			width: 100,
			objectFit: 'contain',
		})
	},
	{
		title: '提交时间',
		key: 'city',
		width: 180,
		render: item => formatTime(item.createTime)
	},
]
